package com.itheima.web.controller;

import com.itheima.web.manager.FreezeManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.aggregation.ArrayOperators;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;
@RestController
public class FreezeCtroller {
    @Autowired
    private FreezeManager freezeManager;
    @PostMapping("/manage/users/freeze")
    public ResponseEntity userFreeze(
            @RequestBody Map<String,String> map
    ){
        String userId =map.get("userId");
        String freezingTime =map.get("freezingTime");
        String freezingRange =map.get("freezingRange");
        String reasonsForFreezing =map.get("reasonsForFreezing");
        String frozenRemarks =map.get("frozenRemarks");
        String message = freezeManager.userFreeze(userId,freezingTime,freezingRange,reasonsForFreezing,frozenRemarks);
        return ResponseEntity.ok(message);
    }
    @PostMapping("/manage/users/unfreeze")
    public ResponseEntity userUnfreeze(
            @RequestBody Map<String,String> map
    ){
        String userId =map.get("userId");
        String reasonsForThawing =map.get("reasonsForThawing");
        String message=freezeManager.userUnfreeze(userId,reasonsForThawing);
        return  ResponseEntity.ok(message);
    }
}
